package com.gusha.dao;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gusha.model.SysAssets;
import com.gusha.model.User;

@Repository
public interface SysAssetsDao extends JpaRepository<SysAssets,BigInteger>,JpaSpecificationExecutor<SysAssets> {

	List<SysAssets> findAllByUserId(User user);
	
	@Query(value="select s from SysAssets s where s.userId=?2 and finishedNum is not 0 and (shoppingType=?1 or shoppingType=4 or shoppingType=5)")
	List<SysAssets> findAllByShoppingTypeAndUserId(BigInteger type, User user);
	
	@Query(value="select s from SysAssets s where s.userId=?1 and finishedNum is not 0 and (shoppingType=?2 or shoppingType=3)")
	List<SysAssets> findAllByUserIdAndShoppingType(User user,BigInteger bigInteger);

	@Query(value="select s from SysAssets s where s.userId=?1 and shoppingNum is not 0 ")
	List<SysAssets> findAllByUser(User user);

	SysAssets findAllById(BigInteger bigInteger);

	List<SysAssets> findByShoppingType(BigInteger bigInteger);

	@Query(value="select s from SysAssets s where s.userId=?1 and shoppingType=?2")
	List<SysAssets> findAllByUserAndShoppingType(User uid, BigInteger type);

	SysAssets findAllByUserIdAndShoppingName(User uid, String commodityName);

}
